package com.BraveY.Demo07;

public class Demo01 {
    public static void main(String[] args) {
        double random = Math.random() * 100;
        System.out.println("随机数为:");
        System.out.println(random);
        String str = random + "";
        int index = str.indexOf(".");
        System.out.println(index);
        String substring = str.substring(0, index + 3);
        System.out.println("转换为:");
        System.out.println(substring);

        int[] arr = {1, -8, -6, 8, 2, -6};
        int[] newArr = new int[arr.length];
        for (int i = 0; i < arr.length; i++) {
            newArr[i] = Math.abs(arr[i]);
        }

        for (int i = 0; i < newArr.length; i++) {
            System.out.print(newArr[i] + ",");
        }
    }
}
